<?php
session_start();
    
    // Created By : Julian Ponce
    // B.S. Computer Science - De La Salle Canlubang
    // January 9, 2012
    // IN PARAMETERS : documentId, userId, remark
    // 
    // This AJAX Request saves the remark of a particular document.

    include('../includes/siteConfig.php');
    // CONNECT TO DATABASE
    $connect = mysql_connect($hostName,$rootName,$dBasePassword) or die ('Unable to connect!');
    mysql_select_db($dBaseName) or die ('Unable to select database!');
    
    $documentId = $_POST['documentId'];
    $userId = $_POST['userId'];
    $remark = $_POST['remark'];
    
    //GET THE CURRENT DATE TIME
    date_default_timezone_set('Asia/Singapore');
    $currentDateTime= date("Y-m-d H:i:s" , time());
    
    // SAVE REMARK
    $query = 
        "
            INSERT INTO Remark (userId, documentId, remark, remarkDateTime)
            VALUES ('$userId', '$documentId', '$remark', '$currentDateTime')
        ";
    mysql_query($query);
   
    echo json_encode(1);
    
    mysql_close($connect);
?>
